<?php
/**
 * Created by PhpStorm.
 * User: xiao
 * Date: 2017/6/30
 * Time: 下午1:33
 */

namespace app\src\withdrawDeposit\action;

use app\src\base\action\BaseAction;
use app\src\base\helper\PageHelper;
use app\src\withdrawDeposit\logic\WithdrawDepositLogic;

class WithdrawDepositAction extends BaseAction {

    /**
     * 添加提现申请
     * @param $type
     * @param $account_id
     * @param $score
     * @param $apply_info
     * @return array
     */
    public function addApply($type, $account_id, $score, $apply_info)
    {
        $result = (new WithdrawDepositLogic)->addApply($type, $account_id, $score, $apply_info);
        return $result;
    }

    /**
     * 查询指定账号提现申请
     * @param $type
     * @param $account_id
     * @param PageHelper $pageHelper
     * @return array
     */
    public function queryApply($type, $account_id, PageHelper $pageHelper, $apply_status = false)
    {
        $map = [
            'type' => $type,
            'account_id' => $account_id,
            'status' => 0
        ];

        $order = [
            'create_time' => 'desc'
        ];

        if($apply_status !== false) {
            $map['apply_status'] = $apply_status;
        }

        $page = ['curpage' => $pageHelper->getPageIndex(), 'size' => $pageHelper->getPageSize()];
        $result = (new WithdrawDepositLogic)->queryWithCount($map, $page, $order);

        return $result;
    }
}